package cn.maihe.elg.operation.supports.guarantee.dto;

import cn.maihe.elg.operation.supports.guarantee.enums.RespCode;
import lombok.Data;

/**
 * @Description
 * @Author caixh
 * @Date 2021/5/18.
 */
@Data
public class BaseResponseDTO<T> {

    private String status;
    private String message;
    private T data;


    private BaseResponseDTO(String status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public static <T> BaseResponseDTO of(String status, String message, T data) {
        return new BaseResponseDTO<T>(status, message, data);
    }

    public static <T> BaseResponseDTO success(T data) {
        return new BaseResponseDTO<T>(RespCode.SUCCESS.getRespCode(), "成功", data);
    }

    public static <T> BaseResponseDTO error(T data) {
        return new BaseResponseDTO<T>(RespCode.FAILURE.getRespCode(), "失败", data);
    }

    public static <T> BaseResponseDTO exception(String message) {
        return new BaseResponseDTO<T>(RespCode.EXCEPTION.getRespCode(), message, null);
    }

    public static <T> BaseResponseDTO exceptionParam(String message) {
        return new BaseResponseDTO<T>(RespCode.NO_PARAM.getRespCode(), message, null);
    }


    public String getstatus() {
        return status;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }
}
